/*
 * Copyright (c)  2020,  DataPipeline
 * All rights reserved.
 *
 * Id:ClobUtils.java   2020-07-18 21:59 wanglijun
 */
package cn.datacare.orm.util;

import java.io.IOException;
import java.io.Reader;
import java.sql.SQLException;

/**
 * <p>
 * Title:
 * </p>
 * <p>
 * Description:
 * </p>
 * <p>
 * Copyright: Copyright (c) 2020
 * </p>
 * <p>
 * Company/Department: DataPipeline
 * </p>
 *
 * @author wanglijun
 * @version 1.0
 * @since 2020-07-18 21:59
 */
public class ClobUtils {

    public static String getString(Reader reader) throws SQLException {
        char[] chars = new char[1024];
        StringBuilder sb = new StringBuilder();
        int len;
        try {
            while ((len = reader.read(chars, 0, 1024)) != -1) {
                sb.append(chars, 0, len);
            }

        } catch (IOException e) {
            throw new SQLException(e);
        } finally {
            IOUtils.closeQuietly(reader);
        }
        return sb.toString();
    }
}
